package com.jy.rhin.infra.repo.notfication.participant.po;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jy.rhin.domain.notification.participant.entity.EnumInteractionType;
import com.jy.rhin.domain.notification.participant.entity.EnumParticipantRole;
import com.jy.rhin.domain.notification.participant.entity.ParticipantDO;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

/**
 * @author dhl
 * @date 2022/6/29
 * @Description
 */
@Data
@NoArgsConstructor
@TableName("t_notification_participant")
public class ParticipantPO {

    public ParticipantDO toDO() {
        ParticipantDO participant = new ParticipantDO();
        participant.setId(this.id);
        participant.setParticipantName(this.participantName);
        participant.setParticipantCode(this.participantCode);
        participant.setInteractionType(EnumInteractionType.valueOf(this.interactionType));
        participant.setParticipantRole("PUBLISHER".equals(this.participantRole) ? EnumParticipantRole.PUBLISHER : EnumParticipantRole.SUBSCRIBER);
        participant.setParticipantUrl(this.participantUrl);
        participant.setParticipantDesc(this.participantDesc);
        participant.setCreateBy(this.createBy);
        participant.setCreateTime(this.getCreateTime());
        participant.setUpdateBy(this.updateBy);
        participant.setUpdateTime(this.getUpdateTime());
        return participant;
    }

    public ParticipantPO(ParticipantDO participant){
        this.id = participant.getId();
        this.participantName = participant.getParticipantName();
        this.participantCode = participant.getParticipantCode();
        this.participantRole = participant.getParticipantRole().name();
        this.interactionType = participant.getInteractionType().name();
        this.participantUrl = participant.getParticipantUrl();
        this.participantDesc = participant.getParticipantDesc();
        this.createBy = participant.getCreateBy();
        this.createTime = participant.getCreateTime();
        this.updateBy = participant.getUpdateBy();
        this.updateTime = participant.getUpdateTime();
    }

    /** id */
    @TableId
    private Long id ;
    /** 参与者名称 */
    @TableField("participant_name")
    private String participantName ;
    /** 参与者代码;全局唯一 */
    @TableField("participant_code")
    private String participantCode ;
    /** 参与者角色;PUBLISHER:发布者, SUBSCRIBER:订阅者 */
    @TableField("participant_role")
    private String participantRole ;
    /** 互动方式; SOAP, HTTP */
    @TableField("interaction_type")
    private String interactionType;
    /** 参与者端口url */
    @TableField("participant_url")
    private String participantUrl ;
    /** 描述 */
    @TableField("participant_desc")
    private String participantDesc ;
    /** 创建人 */
    @TableField("create_by")
    private String createBy ;
    /** 创建时间 */
    @TableField("create_time")
    private Date createTime ;
    /** 更新人 */
    @TableField("update_by")
    private String updateBy ;
    /** 更新时间 */
    @TableField("update_time")
    private Date updateTime ;


}
